﻿namespace IOP.OpenType.Abstractions
{
    /// <summary>
    /// Short offset to a table, same as uint16, NULL offset = 0x0000
    /// </summary>
    public readonly struct Offset16
    {
        private readonly ushort origin;
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="number"></param>
        public Offset16(ushort number) => origin = number;

        /// <summary>
        /// 隐式转换
        /// </summary>
        /// <param name="offset"></param>
        public static implicit operator ushort(Offset16 offset) => offset.origin;
        /// <summary>
        /// 隐式转换
        /// </summary>
        /// <param name="number"></param>
        public static implicit operator Offset16(short number) => new Offset16((ushort)number);
        /// <summary>
        /// 隐式转换
        /// </summary>
        /// <param name="number"></param>
        public static implicit operator Offset16(ushort number) => new Offset16(number);
        /// <summary>
        /// NULL
        /// </summary>
        public static Offset16 NULL => new Offset16(0x0000);
    }
}
